import { NgModule } from '@angular/core'
import { Routes, RouterModule } from '@angular/router'
import { RiskListComponent } from './list/list.component'
import { RiskNewComponent } from './new/new.component'
import { RiskDetailComponent } from './detail/detail.component'
import { NewRouterGuardClass } from '@shared/classes/NewRouterGuardClass'
import { RiskDetailTabRulesComponent } from './detail/tab-rules/tab-rules.component'
import { RiskDetailTabLevelsComponent } from './detail/tab-levels/tab-levels.component'
import { RiskRuleDetailComponent } from './rule/detail/detail.component'
import { RiskRuleNewComponent } from './rule/new/new.component'
import { ListReuseGuardClass } from '@shared/classes/ListReuseGuardClass'

const routes: Routes = [
  { path: '', redirectTo: 'list', pathMatch: 'full' },
  {
    path: 'list',
    component: RiskListComponent,
    canActivate: [ListReuseGuardClass],
    data: {
      title: '风控列表',
      titleI18n: 'MENU.RC.LIST',
      reuse: true
    },
  },
  {
    path: 'new',
    component: RiskNewComponent,
    canDeactivate: [NewRouterGuardClass],
    data: {
      breadcrumb: 'GENERAL.INFO.BREADCRUMB.CREATE',
      titleI18n: 'RISK_CTRL.TITLE.CREATE',
    },
  },
  {
    path: ':id',
    component: RiskDetailComponent,
    children: [
      { path: '', redirectTo: 'rules', pathMatch: 'full' },
      {
        path: 'rules',
        component: RiskDetailTabRulesComponent,
        data: {
          titleI18n: 'RISK_CTRL.TITLE.DETAIL',
        },
      },
      {
        path: 'levels',
        component: RiskDetailTabLevelsComponent,
        data: {
          titleI18n: 'RISK_CTRL.TITLE.DETAIL',
        },
      },
    ],
    data: {
      breadcrumb: 'GENERAL.INFO.BREADCRUMB.DETAIL',
      titleI18n: 'RISK_CTRL.TITLE.DETAIL',
    },
  },
  {
    path: ':id/rules/:type/:ruleId',
    component: RiskRuleDetailComponent,
    data: {
      breadcrumb: '风控规则详情',
      titleI18n: 'RISK_CTRL.RULES.TITLE.DETAIL',
    },
  },
  {
    path: ':id/rules/new',
    component: RiskRuleNewComponent,
    data: {
      breadcrumb: '风控规则新增',
      titleI18n: 'RISK_CTRL.RULES.TITLE.CREATE',
    },
  },
]
@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule],
})
export class RiskRoutingModule {}
